package TCPTest04;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.UUID;

public class Server {

    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(10000);

        UUID uuid = UUID.randomUUID();
        Socket s =  ss.accept();

        BufferedInputStream bis = new BufferedInputStream(s.getInputStream());

        String fN = uuid.toString() ;
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("E:\\webP\\Server\\"+fN+".txt"));

        int len;
        byte[] bytes = new byte[1024];
        while ((len =bis.read(bytes))!=-1){
            bos.write(bytes,0,len);
        }
        bos.flush();

        //资源关闭
        s.close();
        ss.close();

    }
}
